/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2024-06-20
 * Time: 11:03
 */
class SinlgetonLazy1 {
    private static volatile SinlgetonLazy1 instance = null;
    public static SinlgetonLazy1 getInstance() {
        Object locker = new Object();
        if(instance == null) {
            synchronized(locker) {
                if (instance == null ) {
                    instance = new SinlgetonLazy1();
                }
            }
        }
        return instance;
    }
    private SinlgetonLazy1() {

    }
}
public class Deom24 {
    public static void main(String[] args) throws InterruptedException {
        SinlgetonLazy1 s = SinlgetonLazy1.getInstance();
        Thread t1 = new Thread(() -> {
            SinlgetonLazy1 s1 = SinlgetonLazy1.getInstance();
        });
        Thread t2 = new Thread(() -> {
            SinlgetonLazy1 s2 = SinlgetonLazy1.getInstance();
        });
        t1.start();
        t2.start();
    }
}
